/**
 * @properties={typeid:35,uuid:"2C23B783-7042-4850-9A1A-7D8CE3BF99ED",variableType:4}
 */
var fFiltro = 1;

/**
 * @properties={typeid:35,uuid:"899F624D-1B39-4878-99D4-0C6839322E89",variableType:4}
 */
var fChofer_aux = null;

/**
 * @properties={typeid:35,uuid:"5DFAD39C-B8F9-4F9F-AD55-BDBF72979DE0",variableType:4}
 */
var fCliente_aux = null;

/**
 * @properties={typeid:35,uuid:"87E287F3-663A-4D13-8254-C14B9FC4D400",variableType:93}
 */
var fFech_desde = null;

/**
 * @properties={typeid:35,uuid:"FD001DE2-DDF3-45B0-B069-B40D18B98483",variableType:93}
 */
var fFecha_hasta = null;

/**
 * @properties={typeid:35,uuid:"11C022BF-FED6-48D4-B22A-9009CD180B59",variableType:4}
 */
var fFletero_aux = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"73F33332-8702-4B60-B517-66589210D591"}
 */
function onAction_ira_detalle(event) {
	// globals.mostrarForm("viajes_detalle_filtros");   //va a detalle
	//forms.viajes_detalle_filtros.controller.show()
	fFiltro = 0
	globals.mostrarForm("viajes_detalle")
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"B0A8756E-E3F8-4797-BFE0-976946F04FD0"}
 */
function onShow(firstShow, event) {
	// globals.autosaveon();
	databaseManager.setAutoSave(true)
	
	if (fFiltro == 1)
		controller.loadAllRecords()
	
	fFiltro 		= 1
	fChofer_aux		= null
	fCliente_aux 	= null
	fFletero_aux 	= null
	fFecha_hasta 	=  new Date();
	fFech_desde 	= new Date();
	fFech_desde 	= fFech_desde.setDate (fFecha_hasta.getDate() - 30);
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"8B0F278E-E9AA-42EB-99CB-78B1553D5310"}
 */
function buscar(event) {
	// busca según los campos del header
	var found = controller.find()
	if (found=false)
	{
		globals.gMensaje="Error al buscar"
		globals.gMensajes();
		return
	}
	if (fChofer_aux != null)
	{
		choferes_id=fChofer_aux
	}
	if (fCliente_aux != null)
	{
		cliente_id=fCliente_aux
	}
	if (fFletero_aux != null)
	{
		fletero_id=fFletero_aux
	}
	if ((fFech_desde != null) && (fFecha_hasta != null))
		
	{	
	//Rango de Fechas //////////////////////////////
	var d1 = fFech_desde
	d1.setHours(00);
	d1.setMinutes(00);
	d1.setSeconds(00);             
	var df1 = utils.dateFormat(d1, 'dd-MM-yyyy HH:mm:ss')
	
	var d2 = fFecha_hasta
	d2.setHours(23);
	d2.setMinutes(59);
	d2.setSeconds(59);
	var df2 = utils.dateFormat(d2, 'dd-MM-yyyy HH:mm:ss')
	
	 fecha_autorizacion = df1+'...' + df2+'|dd-MM-yyyy HH:mm:ss'
	}
	var cuantos = controller.search(true,false)
	if (cuantos = 0)
	{
		globals.gMensaje="No se encontraron viajes con esas características"
		globals.gMensajes();
		return
	}
	return
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"4E03EC3E-8EA7-48BC-8E0A-A57C438794F4"}
 */
function todos(event) {
	// muestra todos los registros
	controller.loadAllRecords()
}
